use "C:\Users\Andy baker\OneDrive - UCB-O365\My Documents\Research\Paper Book Networks\Chapter 4 Campaigns\Data\when decided 2002.dta", clear

twoway (scatter maxknow x1, mcolor(black) msize(medsmall) msym(o) mcolor(black) connect(l) lwidth(medthick) lcolor(black)) ///
(scatter minknow x2, mcolor(black) msize(small) msym(S) mcolor(black) connect(l) lwidth(medthick) lcolor(black)) ///
(rcap maxlo maxhi x1, lcolor(black) lwidth(medthick)) ///
(rcap minlo minhi x2, lcolor(black) lwidth(medthick)), ///
yscale(range(0 .6)) ylab(0 "0%" .2 "20%" .4 "40%" .6 "60%" .8 "80%", labsize(medium)) xscale(range(.8 3.2)) title("{bf:Brazil 2002}", color(black) size(medlarge)) ///
ytitle("{bf:Model-Predicted}" "{bf:Percentage of Voters}", size(medlarge)) legend(off) graphregion(color(white)) plotregion(lstyle(yxline) ///
lcolor(black)) xlab(1 "B/f campaign" 2 "B/f mid-campaign" 3 "B/f elect. day", labsize(medsmall)) xtitle("{bf:Timing of Vote Decision}", size(medlarge)) ///
text(.55 1.35 "Max" "knowledge", size(medsmall) just(left)) text(.55 2.65 "Min" "knowledge", color(black) size(medsmall) just(right)) text(0 1 "{it:N}=1,761", size(medsmall)) 

graph save "C:\Users\Andy baker\OneDrive - UCB-O365\My Documents\Research\Paper Book Networks\Chapter 4 Campaigns\Figures\Bra2002timing.gph", replace

use "C:\Users\Andy baker\OneDrive - UCB-O365\My Documents\Research\Paper Book Networks\Chapter 4 Campaigns\Data\when decided 2006.dta", clear

twoway (scatter maxknow x1, mcolor(black) msize(medsmall) msym(o) mcolor(black) connect(l) lwidth(medthick) lcolor(black)) ///
(scatter minknow x2, mcolor(black) msize(small) msym(S) mcolor(black) connect(l) lwidth(medthick) lcolor(black)) ///
(rcap maxlo maxhi x1, lcolor(black) lwidth(medthick)) ///
(rcap minlo minhi x2, lcolor(black) lwidth(medthick)), ///
yscale(range(0 .6)) ylab(0 "0%" .2 "20%" .4 "40%" .6 "60%" .8 "80%", labsize(medium)) xscale(range(.8 3.2)) title("{bf:Brazil 2006}", color(black) size(medlarge)) ///
ytitle("{bf:Model-Predicted}" "{bf:Percentage of Voters}", size(medlarge)) legend(off) graphregion(color(white)) plotregion(lstyle(yxline) ///
lcolor(black)) xlab(1 "B/f campaign" 2 "B/f mid-campaign" 3 "B/f elect. day", labsize(medsmall)) xtitle("{bf:Timing of Vote Decision}", size(medlarge)) ///
text(.75 2.39  "Max" "knowledge", size(medsmall) just(left)) text(.26 2.39 "Min" "knowledge", color(black) size(medsmall) just(left)) text(0 1 "{it:N}=1,513", size(medsmall)) 

graph save "C:\Users\Andy baker\OneDrive - UCB-O365\My Documents\Research\Paper Book Networks\Chapter 4 Campaigns\Figures\Bra2006timing.gph", replace

use "C:\Users\Andy baker\OneDrive - UCB-O365\My Documents\Research\Paper Book Networks\Chapter 4 Campaigns\Data\when decided 2014.dta", clear

twoway (scatter maxknow x1, mcolor(black) msize(medsmall) msym(o) mcolor(black) connect(l) lwidth(medthick) lcolor(black)) ///
(scatter minknow x2, mcolor(black) msize(small) msym(S) mcolor(black) connect(l) lwidth(medthick) lcolor(black)) ///
(rcap maxlo maxhi x1, lcolor(black) lwidth(medthick)) ///
(rcap minlo minhi x2, lcolor(black) lwidth(medthick)), ///
yscale(range(0 .6)) ylab(0 "0%" .2 "20%" .4 "40%" .6 "60%" .8 "80%", labsize(medium)) xscale(range(.8 3.2)) title("{bf:Brazil 2014}", color(black) size(medlarge)) ///
ytitle("{bf:Model-Predicted}" "{bf:Percentage of Voters}", size(medlarge)) legend(off) graphregion(color(white)) plotregion(lstyle(yxline) ///
lcolor(black)) xlab(1 "B/f campaign" 2 "B/f mid-campaign" 3 "B/f elect. day", labsize(medsmall)) xtitle("{bf:Timing of Vote Decision}", size(medlarge)) ///
text(.54 1.35   "Max" "knowledge", size(medsmall) just(left)) text(.48 2.65 "Min" "knowledge", color(black) size(medsmall) just(right)) text(0 1 "{it:N}=697", size(medsmall)) 

graph save "C:\Users\Andy baker\OneDrive - UCB-O365\My Documents\Research\Paper Book Networks\Chapter 4 Campaigns\Figures\Bra2014timing2.gph", replace

use "C:\Users\Andy baker\OneDrive - UCB-O365\My Documents\Research\Paper Book Networks\Chapter 4 Campaigns\Data\when decided 2006 m.dta", clear

twoway (scatter maxknow x1, mcolor(black) msize(medsmall) msym(o) mcolor(black) connect(l) lwidth(medthick) lcolor(black)) ///
(scatter minknow x2, mcolor(black) msize(small) msym(S) mcolor(black) connect(l) lwidth(medthick) lcolor(black)) ///
(rcap maxlo maxhi x1, lcolor(black) lwidth(medthick)) ///
(rcap minlo minhi x2, lcolor(black) lwidth(medthick)), ///
yscale(range(0 .6)) ylab(0 "0%" .2 "20%" .4 "40%" .6 "60%" .8 "80%", labsize(medium)) xscale(range(.8 3.2)) title("{bf:Mexico 2006}", color(black) size(medlarge)) ///
ytitle("{bf:Model-Predicted}" "{bf:Percentage of Voters}", size(medlarge)) legend(off) graphregion(color(white)) plotregion(lstyle(yxline) ///
lcolor(black)) xlab(1 "B/f campaign" 2 "B/f mid-campaign" 3 "B/f elect. day", labsize(medsmall)) xtitle("{bf:Timing of Vote Decision}", size(medlarge)) ///
text(.75 1.35  "Max" "knowledge", size(medsmall) just(left)) text(.400 2.66 "Min" "knowledge", color(black) size(medsmall) just(right)) text(0 1 "{it:N}=1,053", size(medsmall)) 

graph save "C:\Users\Andy baker\OneDrive - UCB-O365\My Documents\Research\Paper Book Networks\Chapter 4 Campaigns\Figures\Mex2006timing.gph", replace

*Figure 4.9A
graph combine ///
"C:\Users\Andy baker\OneDrive - UCB-O365\My Documents\Research\Paper Book Networks\Chapter 4 Campaigns\Figures\Bra2002timing.gph" ///
"C:\Users\Andy baker\OneDrive - UCB-O365\My Documents\Research\Paper Book Networks\Chapter 4 Campaigns\Figures\Bra2006timing.gph" ///
"C:\Users\Andy baker\OneDrive - UCB-O365\My Documents\Research\Paper Book Networks\Chapter 4 Campaigns\Figures\Bra2014timing2.gph" ///
"C:\Users\Andy baker\OneDrive - UCB-O365\My Documents\Research\Paper Book Networks\Chapter 4 Campaigns\Figures\Mex2006timing.gph" , ///
row(2) col(2) graphregion(color(white)) xcommon ycommon

graph export "C:\Users\Andy baker\OneDrive - UCB-O365\My Documents\Research\Paper Book Networks\Chapter 4 Campaigns\Figures\timing_all.tif", as(tif) replace
graph export "C:\Users\Andy baker\OneDrive - UCB-O365\My Documents\Research\Paper Book Networks\Publishers\Final Manuscript\Final Figures\BAR4_9A.tif", as(tif) replace width(1500)
graph export "C:\Users\Andy baker\OneDrive - UCB-O365\My Documents\Research\Paper Book Networks\Publishers\Final Manuscript\Final Figures\BAR4_9A.pdf", as(pdf) replace 

